using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Data;
using System.Data.Common;
using Oracle.ManagedDataAccess.Types;
using OracleInternal.Common;

namespace Oracle.ManagedDataAccess.Client
{
	[Designer("Oracle.VsDevTools.OracleVSGDataAdapterWizard, Oracle.VsDevTools, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=X86", typeof(IDesigner))]
	[DefaultEvent("RowUpdated")]
	public sealed class OracleDataAdapter : DbDataAdapter, IDbDataAdapter, IDataAdapter
	{
		private OracleCommand m_selectCommand;

		private OracleCommand m_insertCommand;

		private OracleCommand m_updateCommand;

		private OracleCommand m_deleteCommand;

		private bool m_requery;

		private static readonly object EventRowUpdated = new object();

		private static readonly object EventRowUpdating = new object();

		private int m_updateBatchSize = 1;

		private BatchUpdateHelper m_batchUpdateHelper;

		private bool m_bGBRAInvoked;

		private Array m_errorCodesArray;

		private Array m_errMsgsArray;

		private Array m_rowsModArray;

		internal bool m_bSuppressGetDecimalInvalidCastException;

		[DefaultValue(null)]
		[Description("")]
		[Category("Update")]
		public new OracleCommand DeleteCommand
		{
			get
			{
				return m_deleteCommand;
			}
			set
			{
				m_deleteCommand = value;
			}
		}

		[Description("")]
		[DefaultValue(null)]
		[Category("Update")]
		public new OracleCommand InsertCommand
		{
			get
			{
				return m_insertCommand;
			}
			set
			{
				m_insertCommand = value;
			}
		}

		[Description("")]
		[Category("Fill")]
		[DefaultValue(true)]
		public bool Requery
		{
			get
			{
				return m_requery;
			}
			set
			{
				m_requery = value;
			}
		}

		[Category("Mapping")]
		[Description("")]
		public Hashtable SafeMapping
		{
			get
			{
				throw new NotSupportedException();
			}
		}

		[Description("")]
		[DefaultValue(null)]
		[Category("Fill")]
		public new OracleCommand SelectCommand
		{
			get
			{
				return m_selectCommand;
			}
			set
			{
				m_selectCommand = value;
			}
		}

		IDbCommand IDbDataAdapter.DeleteCommand
		{
			get
			{
				return m_deleteCommand;
			}
			set
			{
				m_deleteCommand = (OracleCommand)value;
			}
		}

		IDbCommand IDbDataAdapter.InsertCommand
		{
			get
			{
				return m_insertCommand;
			}
			set
			{
				m_insertCommand = (OracleCommand)value;
			}
		}

		IDbCommand IDbDataAdapter.SelectCommand
		{
			get
			{
				return m_selectCommand;
			}
			set
			{
				m_selectCommand = (OracleCommand)value;
			}
		}

		IDbCommand IDbDataAdapter.UpdateCommand
		{
			get
			{
				return m_updateCommand;
			}
			set
			{
				m_updateCommand = (OracleCommand)value;
			}
		}

		[Description("")]
		[Category("Update")]
		[DefaultValue(null)]
		public new OracleCommand UpdateCommand
		{
			get
			{
				return m_updateCommand;
			}
			set
			{
				m_updateCommand = value;
			}
		}

		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public bool SuppressGetDecimalInvalidCastException
		{
			get
			{
				return m_bSuppressGetDecimalInvalidCastException;
			}
			set
			{
				m_bSuppressGetDecimalInvalidCastException = value;
			}
		}

		[DefaultValue(1)]
		public override int UpdateBatchSize
		{
			get
			{
				return m_updateBatchSize;
			}
			set
			{
				if (value < 0)
				{
					throw new ArgumentOutOfRangeException();
				}
				m_updateBatchSize = value;
			}
		}

		public event OracleRowUpdatingEventHandler RowUpdating
		{
			add
			{
				base.Events.AddHandler(EventRowUpdating, value);
			}
			remove
			{
				base.Events.RemoveHandler(EventRowUpdating, value);
			}
		}

		public event OracleRowUpdatedEventHandler RowUpdated
		{
			add
			{
				base.Events.AddHandler(EventRowUpdated, value);
			}
			remove
			{
				base.Events.RemoveHandler(EventRowUpdated, value);
			}
		}

		public OracleDataAdapter()
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.ctor);
			}
			try
			{
				m_requery = true;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.ctor, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.ctor);
				}
			}
		}

		public OracleDataAdapter(OracleCommand selectCommand)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.ctor);
			}
			try
			{
				m_requery = true;
				m_selectCommand = selectCommand;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.ctor, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.ctor);
				}
			}
		}

		public OracleDataAdapter(string selectCommandText, OracleConnection selectConnection)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.ctor);
			}
			try
			{
				m_requery = true;
				m_selectCommand = new OracleCommand(selectCommandText, selectConnection);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.ctor, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.ctor);
				}
			}
		}

		public OracleDataAdapter(string selectCommandText, string selectConnectionString)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.ctor);
			}
			try
			{
				m_requery = true;
				m_selectCommand = new OracleCommand(selectCommandText, new OracleConnection(selectConnectionString));
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.ctor, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.ctor);
				}
			}
		}

		public int Fill(DataSet dataSet, OracleRefCursor refCursor)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.Fill);
			}
			try
			{
				string srcTable = "Table";
				int startRecord = 0;
				int maxRecords = 0;
				if (dataSet == null)
				{
					throw new ArgumentNullException("dataSet");
				}
				if (refCursor == null)
				{
					throw new ArgumentNullException("refCursor");
				}
				OracleDataReader dataReader = refCursor.GetDataReader(fillRequest: true);
				if (dataReader.m_internalRowCounter > 0)
				{
					throw new InvalidOperationException(OracleStringResourceManager.GetErrorMesg(ResourceStringConstants.DA_FORWARD_ONLY));
				}
				dataReader.SuppressGetDecimalInvalidCastException = m_bSuppressGetDecimalInvalidCastException;
				int result = 0;
				try
				{
					result = Fill(dataSet, srcTable, dataReader, startRecord, maxRecords);
				}
				finally
				{
					dataReader.Close();
				}
				return result;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.Fill, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.Fill);
				}
			}
		}

		protected override int Fill(DataSet dataSet, string srcTable, IDataReader dataReader, int startRecord, int maxRecords)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.Fill);
			}
			try
			{
				if (dataSet == null)
				{
					throw new ArgumentNullException("dataSet");
				}
				if (dataReader == null)
				{
					throw new ArgumentNullException("dataReader");
				}
				OracleDataReader obj = (OracleDataReader)dataReader;
				obj.IsFillReader = true;
				obj.m_returnPSTypes = ReturnProviderSpecificTypes;
				obj.SuppressGetDecimalInvalidCastException = m_bSuppressGetDecimalInvalidCastException;
				int result = base.Fill(dataSet, srcTable, dataReader, startRecord, maxRecords);
				ArrayList schemaTables = obj.SchemaTables;
				for (int i = 0; i < schemaTables.Count; i++)
				{
					string text = srcTable;
					if (i > 0)
					{
						text = srcTable + i;
					}
					DataTableMapping dataTableMapping = null;
					if (base.TableMappings.IndexOf(text) != -1)
					{
						dataTableMapping = base.TableMappings[text];
					}
					if (dataTableMapping != null)
					{
						text = dataTableMapping.DataSetTable;
					}
					DataTable dataTable = null;
					if (dataSet.Tables.IndexOf(text) != -1)
					{
						dataTable = dataSet.Tables[text];
					}
					if (dataTable != null)
					{
						DataTable schemaTable = (DataTable)schemaTables[i];
						FillingExtendedPropertiesHelper(dataTable, schemaTable, dataTableMapping);
					}
				}
				return result;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.Fill);
				}
			}
		}

		public int Fill(DataTable dataTable, OracleRefCursor refCursor)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.Fill);
			}
			try
			{
				if (dataTable == null)
				{
					throw new ArgumentNullException("dataTable");
				}
				if (refCursor == null)
				{
					throw new ArgumentNullException("refCursor");
				}
				OracleDataReader dataReader = refCursor.GetDataReader(fillRequest: true);
				if (dataReader.m_internalRowCounter > 0)
				{
					throw new InvalidOperationException(OracleStringResourceManager.GetErrorMesg(ResourceStringConstants.DA_FORWARD_ONLY));
				}
				dataReader.SuppressGetDecimalInvalidCastException = m_bSuppressGetDecimalInvalidCastException;
				int result = 0;
				try
				{
					result = Fill(dataTable, dataReader);
				}
				finally
				{
					dataReader.Close();
				}
				return result;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.Fill, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.Fill);
				}
			}
		}

		protected override int Fill(DataTable[] dataTables, int startRecord, int maxRecords, IDbCommand command, CommandBehavior behavior)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.Fill);
			}
			try
			{
				if (dataTables == null)
				{
					throw new ArgumentNullException("dataTables");
				}
				if (command == null)
				{
					throw new ArgumentNullException("command");
				}
				OracleCommand oracleCommand = (OracleCommand)command;
				behavior |= CommandBehavior.SequentialAccess;
				if (base.MissingSchemaAction == MissingSchemaAction.AddWithKey)
				{
					behavior |= CommandBehavior.KeyInfo;
				}
				bool flag = false;
				if (oracleCommand.Connection != null && oracleCommand.Connection.m_connectionState == ConnectionState.Closed)
				{
					flag = true;
				}
				if (oracleCommand.m_commandImpl != null)
				{
					oracleCommand.m_commandImpl.m_bExecutingForFill = true;
					oracleCommand.m_commandImpl.m_bReturnPSTypes = ReturnProviderSpecificTypes;
				}
				OracleDataReader oracleDataReader = null;
				try
				{
					oracleDataReader = oracleCommand.ExecuteReader(m_requery, fillRequest: true, behavior);
				}
				catch
				{
					if (flag && oracleCommand.Connection.m_connectionState == ConnectionState.Open)
					{
						try
						{
							oracleCommand.Connection.Close();
						}
						catch
						{
						}
					}
					throw;
				}
				finally
				{
					if (oracleCommand.m_commandImpl != null)
					{
						oracleCommand.m_commandImpl.m_bExecutingForFill = false;
						oracleCommand.m_commandImpl.m_bReturnPSTypes = false;
					}
				}
				oracleDataReader.IsFillReader = true;
				oracleDataReader.m_returnPSTypes = ReturnProviderSpecificTypes;
				if (!m_requery)
				{
					int currentRow = oracleDataReader.CurrentRow;
					startRecord -= currentRow;
					if (startRecord < 0)
					{
						throw new InvalidOperationException(OracleStringResourceManager.GetErrorMesg(ResourceStringConstants.DA_FORWARD_ONLY));
					}
				}
				oracleDataReader.SuppressGetDecimalInvalidCastException = m_bSuppressGetDecimalInvalidCastException;
				int result = 0;
				try
				{
					result = base.Fill(dataTables, oracleDataReader, startRecord, maxRecords);
					ArrayList schemaTables = oracleDataReader.SchemaTables;
					for (int i = 0; i < schemaTables.Count; i++)
					{
						DataTable dataTable = dataTables[i];
						DataTable schemaTable = (DataTable)schemaTables[i];
						FillingExtendedProperties(dataTable, schemaTable);
					}
				}
				finally
				{
					if (oracleDataReader.m_bEndOfFile || m_requery)
					{
						oracleDataReader.Close();
					}
				}
				oracleDataReader = null;
				return result;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.Fill);
				}
			}
		}

		private void FillingExtendedProperties(DataTable dataTable, DataTable schemaTable)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.FillingExtendedProperties);
			}
			try
			{
				DataTableMapping dtm = null;
				if (base.TableMappings.IndexOfDataSetTable(dataTable.TableName) != -1)
				{
					dtm = base.TableMappings.GetByDataSetTable(dataTable.TableName);
				}
				FillingExtendedPropertiesHelper(dataTable, schemaTable, dtm);
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.FillingExtendedProperties);
				}
			}
		}

		private void FillingExtendedPropertiesHelper(DataTable dataTable, DataTable schemaTable, DataTableMapping dtm)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.FillingExtendedPropertiesHelper);
			}
			try
			{
				int num = 0;
				Hashtable hashtable = new Hashtable();
				Hashtable hashtable2 = new Hashtable();
				while (dataTable.ExtendedProperties.ContainsKey("BaseTable." + num))
				{
					num++;
				}
				if (schemaTable.ExtendedProperties.ContainsKey("REFCursorName"))
				{
					dataTable.ExtendedProperties["REFCursorName"] = schemaTable.ExtendedProperties["REFCursorName"];
				}
				bool flag = false;
				foreach (DataRow row in schemaTable.Rows)
				{
					if (!row.IsNull("ColumnName"))
					{
						hashtable[(string)row["ColumnName"]] = true;
					}
					if (!flag && !row.IsNull("BaseSchemaName"))
					{
						dataTable.ExtendedProperties["BaseSchema"] = (string)row["BaseSchemaName"];
						flag = true;
					}
				}
				foreach (DataRow row2 in schemaTable.Rows)
				{
					if (!row2.IsNull("BaseTableName") && !dataTable.ExtendedProperties.ContainsValue(row2["BaseTableName"]))
					{
						dataTable.ExtendedProperties["BaseTable." + num] = (string)row2["BaseTableName"];
						num++;
					}
					if (row2.IsNull("ColumnName"))
					{
						continue;
					}
					string text = (string)row2["ColumnName"];
					string text2 = text;
					if (hashtable2[text2] == null)
					{
						hashtable2[text2] = true;
					}
					else
					{
						int num2 = 0;
						while (hashtable[text2] != null)
						{
							num2++;
							text2 = text + num2;
						}
						hashtable[text2] = true;
					}
					if (dtm != null)
					{
						DataColumnMapping columnMappingBySchemaAction = dtm.GetColumnMappingBySchemaAction(text2, base.MissingMappingAction);
						if (columnMappingBySchemaAction != null)
						{
							text2 = columnMappingBySchemaAction.DataSetColumn;
						}
					}
					DataColumn dataColumn = null;
					if (dataTable.Columns.IndexOf(text2) != -1)
					{
						dataColumn = dataTable.Columns[text2];
					}
					if (dataColumn != null)
					{
						if (!row2.IsNull("BaseColumnName"))
						{
							dataColumn.ExtendedProperties["BaseColumn"] = (string)row2["BaseColumnName"];
						}
						if (!row2.IsNull("OraDbType"))
						{
							dataColumn.ExtendedProperties["OraDbType"] = (int)row2["OraDbType"];
						}
					}
				}
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.FillingExtendedPropertiesHelper);
				}
			}
		}

		public int Fill(DataSet dataSet, string srcTable, OracleRefCursor refCursor)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.Fill);
			}
			try
			{
				int startRecord = 0;
				int maxRecords = 0;
				if (dataSet == null)
				{
					throw new ArgumentNullException("dataSet");
				}
				if (refCursor == null)
				{
					throw new ArgumentNullException("refCursor");
				}
				OracleDataReader dataReader = refCursor.GetDataReader(fillRequest: true);
				if (dataReader.m_internalRowCounter > 0)
				{
					throw new InvalidOperationException(OracleStringResourceManager.GetErrorMesg(ResourceStringConstants.DA_FORWARD_ONLY));
				}
				dataReader.SuppressGetDecimalInvalidCastException = m_bSuppressGetDecimalInvalidCastException;
				int result = 0;
				try
				{
					result = Fill(dataSet, srcTable, dataReader, startRecord, maxRecords);
				}
				finally
				{
					dataReader.Close();
				}
				return result;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.Fill, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.Fill);
				}
			}
		}

		protected override int Fill(DataTable dataTable, IDataReader dataReader)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.Fill);
			}
			try
			{
				if (dataTable == null)
				{
					throw new ArgumentNullException("dataTable");
				}
				if (dataReader == null)
				{
					throw new ArgumentNullException("dataReader");
				}
				OracleDataReader obj = (OracleDataReader)dataReader;
				obj.IsFillReader = true;
				obj.m_returnPSTypes = ReturnProviderSpecificTypes;
				obj.SuppressGetDecimalInvalidCastException = m_bSuppressGetDecimalInvalidCastException;
				int result = base.Fill(dataTable, dataReader);
				ArrayList schemaTables = obj.SchemaTables;
				for (int i = 0; i < schemaTables.Count; i++)
				{
					DataTable schemaTable = (DataTable)schemaTables[i];
					FillingExtendedProperties(dataTable, schemaTable);
				}
				return result;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.Fill);
				}
			}
		}

		protected override int Fill(DataTable dataTable, IDbCommand command, CommandBehavior behavior)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.Fill);
			}
			try
			{
				if (dataTable == null)
				{
					throw new ArgumentNullException("dataTable");
				}
				if (command == null)
				{
					throw new ArgumentNullException("command");
				}
				OracleCommand oracleCommand = (OracleCommand)command;
				behavior = behavior | CommandBehavior.SingleResult | CommandBehavior.SequentialAccess;
				if (base.MissingSchemaAction == MissingSchemaAction.AddWithKey)
				{
					behavior |= CommandBehavior.KeyInfo;
				}
				bool flag = false;
				if (oracleCommand.Connection != null && oracleCommand.Connection.m_connectionState == ConnectionState.Closed)
				{
					flag = true;
				}
				if (oracleCommand.m_commandImpl != null)
				{
					oracleCommand.m_commandImpl.m_bExecutingForFill = true;
					oracleCommand.m_commandImpl.m_bReturnPSTypes = ReturnProviderSpecificTypes;
				}
				OracleDataReader oracleDataReader;
				try
				{
					oracleDataReader = oracleCommand.ExecuteReader(m_requery, fillRequest: true, behavior);
				}
				catch
				{
					if (flag && oracleCommand.Connection.m_connectionState == ConnectionState.Open)
					{
						try
						{
							oracleCommand.Connection.Close();
						}
						catch
						{
						}
					}
					throw;
				}
				finally
				{
					if (oracleCommand.m_commandImpl != null)
					{
						oracleCommand.m_commandImpl.m_bExecutingForFill = false;
						oracleCommand.m_commandImpl.m_bReturnPSTypes = false;
					}
				}
				if (!m_requery && oracleDataReader.m_internalRowCounter > 0)
				{
					throw new InvalidOperationException(OracleStringResourceManager.GetErrorMesg(ResourceStringConstants.DA_FORWARD_ONLY));
				}
				oracleDataReader.SuppressGetDecimalInvalidCastException = m_bSuppressGetDecimalInvalidCastException;
				int result = 0;
				try
				{
					result = Fill(dataTable, oracleDataReader);
				}
				finally
				{
					oracleDataReader.Close();
				}
				oracleCommand = null;
				oracleDataReader = null;
				return result;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.Fill);
				}
			}
		}

		public int Fill(DataSet dataSet, int startRecord, int maxRecords, string srcTable, OracleRefCursor refCursor)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.Fill);
			}
			try
			{
				if (dataSet == null)
				{
					throw new ArgumentNullException("dataSet");
				}
				if (refCursor == null)
				{
					throw new ArgumentNullException("refCursor");
				}
				OracleDataReader dataReader = refCursor.GetDataReader(fillRequest: true);
				int currentRow = dataReader.CurrentRow;
				startRecord -= currentRow;
				if (startRecord < 0)
				{
					throw new InvalidOperationException(OracleStringResourceManager.GetErrorMesg(ResourceStringConstants.DA_FORWARD_ONLY));
				}
				dataReader.SuppressGetDecimalInvalidCastException = m_bSuppressGetDecimalInvalidCastException;
				int result = 0;
				try
				{
					result = Fill(dataSet, srcTable, dataReader, startRecord, maxRecords);
				}
				finally
				{
					if (dataReader.m_bEndOfFile)
					{
						dataReader.Close();
					}
				}
				return result;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.Fill, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.Fill);
				}
			}
		}

		protected override int Fill(DataSet dataSet, int startRecord, int maxRecords, string srcTable, IDbCommand command, CommandBehavior behavior)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.Fill);
			}
			try
			{
				if (dataSet == null)
				{
					throw new ArgumentNullException("dataSet");
				}
				if (command == null)
				{
					throw new ArgumentNullException("command");
				}
				OracleCommand oracleCommand = (OracleCommand)command;
				if (oracleCommand.Connection == null)
				{
					throw new InvalidOperationException();
				}
				behavior |= CommandBehavior.SequentialAccess;
				if (base.MissingSchemaAction == MissingSchemaAction.AddWithKey)
				{
					behavior |= CommandBehavior.KeyInfo;
				}
				bool flag = false;
				if (oracleCommand.Connection != null && oracleCommand.Connection.m_connectionState == ConnectionState.Closed)
				{
					flag = true;
				}
				if (oracleCommand.m_commandImpl != null)
				{
					oracleCommand.m_commandImpl.m_bExecutingForFill = true;
					oracleCommand.m_commandImpl.m_bReturnPSTypes = ReturnProviderSpecificTypes;
				}
				OracleDataReader oracleDataReader;
				try
				{
					oracleDataReader = oracleCommand.ExecuteReader(m_requery, fillRequest: true, behavior);
				}
				catch
				{
					if (flag && oracleCommand.Connection.m_connectionState == ConnectionState.Open)
					{
						try
						{
							oracleCommand.Connection.Close();
						}
						catch
						{
						}
					}
					throw;
				}
				finally
				{
					if (oracleCommand.m_commandImpl != null)
					{
						oracleCommand.m_commandImpl.m_bExecutingForFill = false;
						oracleCommand.m_commandImpl.m_bReturnPSTypes = false;
					}
				}
				if (!m_requery)
				{
					int currentRow = oracleDataReader.CurrentRow;
					startRecord -= currentRow;
					if (startRecord < 0)
					{
						throw new InvalidOperationException(OracleStringResourceManager.GetErrorMesg(ResourceStringConstants.DA_FORWARD_ONLY));
					}
				}
				oracleDataReader.SuppressGetDecimalInvalidCastException = m_bSuppressGetDecimalInvalidCastException;
				int result = 0;
				try
				{
					result = Fill(dataSet, srcTable, oracleDataReader, startRecord, maxRecords);
				}
				finally
				{
					if (oracleDataReader.m_bEndOfFile || m_requery)
					{
						oracleDataReader.Close();
					}
				}
				return result;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.Fill);
				}
			}
		}

		protected override DataTable FillSchema(DataTable dataTable, SchemaType schemaType, IDbCommand command, CommandBehavior behavior)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.FillSchema);
			}
			try
			{
				if (dataTable == null)
				{
					throw new ArgumentNullException("dataTable");
				}
				if (command == null)
				{
					throw new ArgumentNullException("command");
				}
				OracleCommand oracleCommand = (OracleCommand)command;
				oracleCommand.m_returnPSTypes = ReturnProviderSpecificTypes;
				DataTable result = null;
				try
				{
					result = base.FillSchema(dataTable, schemaType, command, behavior);
				}
				finally
				{
					oracleCommand.m_returnPSTypes = false;
				}
				oracleCommand = null;
				return result;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.FillSchema);
				}
			}
		}

		protected override DataTable[] FillSchema(DataSet dataSet, SchemaType schemaType, IDbCommand command, string srcTable, CommandBehavior behavior)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.FillSchema);
			}
			try
			{
				if (dataSet == null)
				{
					throw new ArgumentNullException("dataSet");
				}
				if (command == null)
				{
					throw new ArgumentNullException("command");
				}
				OracleCommand oracleCommand = (OracleCommand)command;
				oracleCommand.m_returnPSTypes = ReturnProviderSpecificTypes;
				DataTable[] result = null;
				try
				{
					result = base.FillSchema(dataSet, schemaType, command, srcTable, behavior);
				}
				finally
				{
					oracleCommand.m_returnPSTypes = false;
				}
				oracleCommand = null;
				return result;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.FillSchema);
				}
			}
		}

		protected override int Update(DataRow[] dataRows, DataTableMapping tableMapping)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.Update);
			}
			try
			{
				if (m_selectCommand == null || m_selectCommand.Connection == null)
				{
					return base.Update(dataRows, tableMapping);
				}
				if (m_selectCommand.Connection.State == ConnectionState.Closed)
				{
					try
					{
						try
						{
							m_selectCommand.Connection.Open();
						}
						catch
						{
						}
						return base.Update(dataRows, tableMapping);
					}
					finally
					{
						if (m_selectCommand.Connection.State == ConnectionState.Open)
						{
							m_selectCommand.Connection.Close();
						}
					}
				}
				return base.Update(dataRows, tableMapping);
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.Update);
				}
			}
		}

		protected override RowUpdatedEventArgs CreateRowUpdatedEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
		{
			return new OracleRowUpdatedEventArgs(dataRow, command, statementType, tableMapping);
		}

		protected override RowUpdatingEventArgs CreateRowUpdatingEvent(DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping)
		{
			return new OracleRowUpdatingEventArgs(dataRow, command, statementType, tableMapping);
		}

		protected override void OnRowUpdating(RowUpdatingEventArgs value)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.OnRowUpdating);
			}
			try
			{
				OracleRowUpdatingEventHandler oracleRowUpdatingEventHandler = (OracleRowUpdatingEventHandler)base.Events[EventRowUpdating];
				OracleRowUpdatingEventArgs e;
				if (oracleRowUpdatingEventHandler != null && (e = value as OracleRowUpdatingEventArgs) != null)
				{
					oracleRowUpdatingEventHandler(this, e);
				}
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.OnRowUpdating);
				}
			}
		}

		protected override void OnRowUpdated(RowUpdatedEventArgs value)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.OnRowUpdated);
			}
			try
			{
				if (!ConfigBaseClass.m_RevertBUErrHandling && !m_bGBRAInvoked && m_updateBatchSize > 1 && value.Errors == null && m_batchUpdateHelper != null)
				{
					int num = 0;
					int length = m_rowsModArray.Length;
					for (int i = 0; i < length; i++)
					{
						if ((int)m_rowsModArray.GetValue(i) > 0)
						{
							num++;
						}
					}
					if (num < length)
					{
						value.Errors = new DBConcurrencyException();
					}
				}
				OracleRowUpdatedEventHandler oracleRowUpdatedEventHandler = (OracleRowUpdatedEventHandler)base.Events[EventRowUpdated];
				OracleRowUpdatedEventArgs e;
				if (oracleRowUpdatedEventHandler != null && (e = value as OracleRowUpdatedEventArgs) != null)
				{
					oracleRowUpdatedEventHandler(this, e);
				}
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.OnRowUpdated);
				}
			}
		}

		protected override void InitializeBatching()
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.InitializeBatching);
			}
			try
			{
				OracleCommand insertCommand = InsertCommand;
				OracleCommand deleteCommand = DeleteCommand;
				OracleCommand updateCommand = UpdateCommand;
				bool flag = false;
				if (insertCommand == null)
				{
					if (updateCommand != null && deleteCommand != null && deleteCommand.BindByName != updateCommand.BindByName)
					{
						flag = true;
					}
				}
				else if (updateCommand == null)
				{
					if (deleteCommand != null && deleteCommand.BindByName != insertCommand.BindByName)
					{
						flag = true;
					}
				}
				else if (updateCommand.BindByName != insertCommand.BindByName)
				{
					flag = true;
				}
				else if (deleteCommand != null && updateCommand.BindByName != deleteCommand.BindByName)
				{
					flag = true;
				}
				if (flag)
				{
					throw new InvalidOperationException(OracleStringResourceManager.GetErrorMesg(ResourceStringConstants.DA_BU_BIND_VIOLATION));
				}
				if (m_batchUpdateHelper == null)
				{
					m_batchUpdateHelper = new BatchUpdateHelper();
				}
				m_batchUpdateHelper.InitializeBUC();
				OracleCommand oracleCommand = UpdateCommand;
				if (oracleCommand == null)
				{
					oracleCommand = DeleteCommand;
					if (oracleCommand == null)
					{
						oracleCommand = InsertCommand;
						if (oracleCommand == null)
						{
							oracleCommand = SelectCommand;
						}
					}
				}
				if (oracleCommand != null)
				{
					m_batchUpdateHelper.BatchUpdateCommand.Connection = oracleCommand.Connection;
					m_batchUpdateHelper.BatchUpdateCommand.CommandTimeout = oracleCommand.CommandTimeout;
					m_batchUpdateHelper.BatchUpdateCommand.BindByName = oracleCommand.BindByName;
				}
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.InitializeBatching);
				}
			}
		}

		protected override int AddToBatch(IDbCommand command)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.AddToBatch);
			}
			try
			{
				if (m_batchUpdateHelper != null)
				{
					return m_batchUpdateHelper.AddCommand(command as OracleCommand);
				}
				return -1;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.AddToBatch);
				}
			}
		}

		protected override void ClearBatch()
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.ClearBatch);
			}
			try
			{
				if (m_batchUpdateHelper != null)
				{
					m_batchUpdateHelper.InitializeBUC();
				}
				m_errorCodesArray = null;
				m_errMsgsArray = null;
				m_rowsModArray = null;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.ClearBatch);
				}
			}
		}

		protected override IDataParameter GetBatchedParameter(int commandIdentifier, int parameterIndex)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.GetBatchedParameter);
			}
			try
			{
				if (m_batchUpdateHelper != null)
				{
					return m_batchUpdateHelper.GetBatchedParameter(commandIdentifier, parameterIndex);
				}
				return null;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.GetBatchedParameter);
				}
			}
		}

		protected override int ExecuteBatch()
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.ExecuteBatch);
			}
			try
			{
				int result = 0;
				if (m_batchUpdateHelper != null)
				{
					m_batchUpdateHelper.FinalizeBUC();
					m_batchUpdateHelper.BatchUpdateCommand.ExecuteNonQuery();
					OracleParameterCollection parameters = m_batchUpdateHelper.BatchUpdateCommand.Parameters;
					m_errorCodesArray = parameters["aecd"].Value as Array;
					m_errMsgsArray = parameters["aem"].Value as Array;
					m_rowsModArray = parameters["armd"].Value as Array;
					OracleErrorCollection oracleErrorCollection = new OracleErrorCollection();
					int length = m_rowsModArray.Length;
					for (int i = 0; i < length; i++)
					{
						if ((int)m_rowsModArray.GetValue(i) == 0)
						{
							int num = (int)m_errorCodesArray.GetValue(i);
							if (num != 0)
							{
								string errMsg = (string)m_errMsgsArray.GetValue(i);
								OracleError value = new OracleError(num, string.Empty, string.Empty, errMsg);
								oracleErrorCollection.Add(value);
							}
						}
					}
					if (oracleErrorCollection.Count > 0)
					{
						throw new OracleException(oracleErrorCollection);
					}
					result = (int)parameters["rmd"].Value;
				}
				return result;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.ExecuteBatch);
				}
			}
		}

		protected override void TerminateBatching()
		{
		}

		protected override bool GetBatchedRecordsAffected(int commandIdentifier, out int recordsAffected, out Exception error)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.GetBatchedRecordsAffected);
			}
			try
			{
				m_bGBRAInvoked = true;
				recordsAffected = 0;
				error = null;
				if (m_rowsModArray.Length <= commandIdentifier)
				{
					return false;
				}
				recordsAffected = (int)m_rowsModArray.GetValue(commandIdentifier);
				if (recordsAffected == 0)
				{
					int num = (int)m_errorCodesArray.GetValue(commandIdentifier);
					if (num != 0)
					{
						string errMsg = (string)m_errMsgsArray.GetValue(commandIdentifier);
						error = new OracleException(num, string.Empty, string.Empty, errMsg);
					}
				}
				return true;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.GetBatchedRecordsAffected);
				}
			}
		}

		protected override void Dispose(bool disposing)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.Dispose);
			}
			try
			{
				base.Dispose(disposing);
			}
			catch
			{
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDataAdapter, OracleTraceFuncName.Dispose);
				}
			}
		}
	}
}
